package com.emep.emeptime.controller;

import com.emep.emeptime.service.aqi.AqiNumberOfDaysService;
import com.emep.emeptime.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.ParseException;

/**
 * @author wangcc
 * @version V1.0
 * @Description: 计算重污染和优良
 * @date 2018/3/30  14:39
 */
@Component
@Slf4j
public class AqiNumberOfDays {

    @Autowired
    private AqiNumberOfDaysService aqiNumberOfDaysService;

    /**
     *优良天数，重污染天数，pm2.5已达数值 每天晚上23点57执行
     */
    @Scheduled(cron = "0 57 23 * * ?")
    //@Scheduled(cron="0/2 * * * * *")
    public void time() throws ParseException {
        log.info("*******************  优良天数，重污染天数，pm2.5已达数值  开始时间：{}", DateUtils.getNowTime());
        aqiNumberOfDaysService.save();

    }

}
